<?php

class delivery_rate
{
        public $seq;
        public $delivery_Ids;
		public $weight_start;
		public $weight_end;
        public $price;
      
	   function  set($di,$ws,$we,$p)
        {
        $this->seq=null;
		$this->delivery_Ids=trim($di);
        $this->weight_start=trim($ws);
        $this->weight_end=trim($we);
        $this->price=trim($p);
		
        }
       private function  check()
	   {
		   
		   if(!empty($this->delivery_Ids) && !empty($this->weight_start) && !empty($this->weight_end) && isset($this->price))
	   {echo "t";return TRUE;}
		  
		   else
		  { echo "f";return FALSE;}
	   }
        function  insert()
        {
            if($this->check())
            {
              require_once('../Connections/conn.php');
                $sql="INSERT INTO sme_delivery_rate
                      VALUES ( null,
					  '$this->delivery_Ids',
					  '$this->weight_start',
					  '$this->weight_end',
					  '$this->price'
					  )";
					  
                if(mysql_query( $sql ))return TRUE;
                else return FALSE;
            }
            else return FALSE;
        }
		function delete($del)
		{
			require_once('../Connections/conn.php');
			$sql="DELETE FROM sme_delivery_rate WHERE  seq = $del";
			mysql_query( $sql );
		}
		function update($up,$p)
		{
			if(!empty($up) && !empty($p))
            {
			require_once('../Connections/conn.php');
			$sql="UPDATE sme_delivery_rate SET 
			price = '$p'
			WHERE seq =$up ; ";
			echo $sql;
			if(mysql_query( $sql ))return TRUE;
            else return FALSE;
			}
            else return FALSE;
		}
		function checkParentRecord($rec)
		{
			require_once('../Connections/conn.php');
			$sql="SELECT COUNT(delivery_id) AS count FROM sme_delivery_type WHERE delivery_Id=$rec";
			$recSql = mysql_query( $sql);
            $record=mysql_fetch_assoc($recSql);
			if($record["count"]>0)  return TRUE;
            else return FALSE;
			
		}
}



?>

